home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1988 April / Ahoy_Magazine_88-04_1988_Double_L.d64 / Random Walk 2 (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  947b  |  36 lines

  1. 1 rem ================================
  2. 2 rem    commodares problem #48-2
  3. 3 rem      random walk
  4. 4 rem    solution by
  5. 5 rem      paul sobolik
  6. 6 rem ====== c-64 only  ==============
  7. 10 c0=49152
  8. 20 for x=0 to 4*8
  9. 30 :   read a
  10. 40 :   poke c0+x,a
  11. 50 next
  12. 60 for x=0 to 8:poke c0+32*8+x,0:next
  13. 70 v1=peek(56576):v2=peek(53272):os=peek(648)
  14. 80 poke 53272,16:poke 56576,v1 and 252:poke 648,(c0+1024)/256
  15. 90 print"[147]";
  16. 100 data 24,60,126,255,24,24,24,24: rem up arrow
  17. 110 data 24,24,24,24,255,126,60,24: rem down arrow
  18. 120 data 16,48,112,255,255,112,48,16: rem left arrow
  19. 130 data 8,12,14,255,255,14,12,8,0: rem right arrow
  20. 140 xp = 211:yp = 214
  21. 150 dim a$(4)
  22. 160 a$(0)="@[157][145]": rem up
  23. 170 a$(1)="a[157]": rem down
  24. 180 a$(2)="c[157][157]": rem left
  25. 190 a$(3)="b"  : rem right
  26. 200 x=int(rnd(1)*4)
  27. 210 cx=peek(xp)
  28. 220 cy=peek(yp)
  29. 230 if x=0 and cy=0 then  280
  30. 240 if x=1 and cy=24 then 280
  31. 250 if x=2 and (cx=0 or cx=40) then 280
  32. 260 if x=3 and (cx=39 or cx=79) then 280
  33. 270 printa$(x);
  34. 280 geta$:ifa$=""then200
  35. 290 poke 648,os:poke53272,v2:poke 56576,v1
  36.